package com.ruoyi.paipan.common;

import com.ruoyi.paipan.utils.LunarUtil;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

public class LiuNian {
    private int index;
    private DaYun daYun;
    private int year;
    private int age;
    private Lunar lunar;

    public LiuNian( DaYun daYun,int index) {
        this.daYun = daYun;
        this.lunar = daYun.getLunar();
        this.index = index;
        this.year = daYun.getStartYear() + index;
        this.age = daYun.getStartAge() + index;
    }
    

    public int getIndex()
    {
        return this.index;
    }

    public DaYun getDaYun()
    {
        return this.daYun;
    }

    public int getYear()
    {
        return this.year;
    }

    public int getAge()
    {
        return this.age;
    }

    public Lunar getLunar()
    {
        return this.lunar;
    }

    public String getGanZhi()
    {
        LinkedHashMap<String, Solar>  jieQi = this.lunar.getJieQiTable();
        int offset = LunarUtil.getJiaZiIndex(jieQi.get("立春").getLunar().getYearInGanZhiExact()) + this.index;
        if (this.daYun.getIndex() > 0) {
            offset += this.daYun.getStartAge() - 1;
        }
        offset %= LunarUtil.JIA_ZI.size();
        return LunarUtil.JIA_ZI.get(offset);
    }

    public String getXun()
    {
        return LunarUtil.getXun(this.getGanZhi());
    }

    public String getXunKong()
    {
        return LunarUtil.getXunKong(this.getGanZhi());
    }

    public List<LiuYue> getLiuYue()
    {
        int n = 12;
        List<LiuYue> l = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            l.add(new LiuYue(this, i));
        }
        return l;
    }
}
